<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>public/assets/css/h5/list.css">

<img  class="topimg" src="<?php echo base_url()?>public/assets/images/h5/banner.jpg">

<div class="detial">
    <p class="name"><?php echo $cl_info['title']?><a href="<?php echo base_url()?>index/cplist_detail?clid=<?php echo $cl_info['id']?>" class="em">查看详情</a></p>
    <?php if(mb_strlen($cl_info['intro'], 'UTF-8') > 50){?>
    <p><?php echo mb_substr($cl_info['intro'], 0, 50, 'UTF-8')?></p>
    <?php }else{?>
    <p><?php echo $cl_info['intro']?></p>
    <?php }?>
</div>

<?php if($cp_evaluate_info){?>
<div class="detial">
    <p class="name">用户评价<a href="<?php echo base_url()?>index/cplist_evaluate?clid=<?php echo $cl_info['id']?>" class="em">查看详情</a></p>
    
    <ul class="conmand">
    <?php foreach ($cp_evaluate_info as $k=>$v){?>
        <li>
            <p>
            <?php for ($i=1;$i<6;$i++){?>
                <i class="fa fa-star" <?php echo $i>$v['star']? 'style="color:#ccc;"':''?>></i>
            <?php }?>
                <em><?php echo $v['create_date']?></em>
            </p>
            <span><?php echo $v['message'];?></span>
        </li>
    <?php }?>
    </ul>
</div>
<?php }?>

<div class="detial">
    <p class="name">购买课包</p>
    
    <?php foreach ($cp_info as $k=>$v){?>
    <div class="weui_media_box weui_media_text">
        <h4 style="margin-bottom: 4px;" class="weui_media_title"><?php echo $v['title']?><?php echo $v['type']!=1 ? '（体验课包）': '（正式课包）' ?></h4>
        <p class="weui_media_desc">共<?php echo $v['hours']?>课时<?php echo $v['type'] != 1 ? '，只能购买一次' : ''?></p>
        
        <?php if($v['give_hours'] != 0){?>
        <p class="weui_media_desc">赠送<?php echo $v['give_hours']?>课时</p>
        <?php }?>
        <?php if($v['expiry_date'] != '0000-00-00'){ ?>
        <p class="weui_media_desc">有效期至 <?php echo $v['expiry_date'];?></p>
        <?php }?>
        
        <p style="<?php echo $v['type'] != 1 ? 'color:#f96a92' : ''?>" class="weui_media_desc">原价<?php echo $v['cost_price']?>元，现价只要<?php echo $v['sale_price']?>元！</p>
        
        <a style="color:#f96a92;top:10%;" href="javascript:go_pay(<?php echo $v['id']?>);" class="weui_btn weui_btn_mini weui_btn_default">购买</a>
    </div>
    <?php }?>
</div>


<!--未登录框-->
<div class="weui_dialog_confirm" id="dialog_login" style="display: none;">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <br>
        <div class="weui_dialog_hd"><strong class="weui_dialog_title">您还没有登录</strong></div>
        <br>
        <div class="weui_dialog_ft">
            <a href="javascript:void(0);" class="weui_btn_dialog default">取消</a>
            <?php 
            $get = $this->input->get() ? $this->input->get() : array();
            $r_url = base_url() . uri_string() ."?". http_build_query($get);
            $return_url = base_url().'login'.'?url='. urlencode($r_url);
            ?>
            <a href="<?php echo $return_url?>" class="weui_btn_dialog primary">现在去登录</a>
        </div>
    </div>
</div>

<!--老师不能购买-->
<div class="weui_dialog_alert" id="dialog_teacher" style="display: none;">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd"><strong class="weui_dialog_title"></strong></div>
        <div class="weui_dialog_bd">老师不支持买课</div>
        <div class="weui_dialog_ft">
            <a href="javascript:void(0);" class="weui_btn_dialog primary">确定</a>
        </div>
    </div>
</div>
        
<script type="text/javascript">

    $(document).ready(function(){
        $(".weui_dialog_confirm .default").click(function(){
            $(this).parents(".weui_dialog_confirm").hide();
        });

        $(".weui_dialog_alert .primary").click(function(){
            $(this).parents(".weui_dialog_alert").hide();
        });
    });

    function go_pay(cp_id){
        if(!<?php echo $this->_uid?>){
            $("#dialog_login").show();
            return false;
        }else if(<?php echo $this->_is_teacher?>){
        	$("#dialog_teacher").show();
            return false;
        }else{
            location.href = '<?php echo base_url()?>order/pay?cp_id='+cp_id;
        }
     }

</script>
